
var toast = function (msg) {
  return new Promise((resolve, reject) => {
    uni.showToast({
      title: msg,
      icon: 'none',
      duration: 1500,
      success: () => {
        setTimeout(() => {
          resolve('')
        }, 1500)
      }
    })
  })
}

var strToArray = function (images) {
  if (images && images.indexOf(',') > -1) {
    return images.split(',')
  } else {
    return [images]
  }
}
var getData = function (date, type) {
  date = new Date(date * 1000)
  if (type == 'time') {
    return date.toTimeString().substr(0, 8)
  } else if (type == 'date') {
    return date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate()
  } else {
    return (
      date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate() +
      " " +
      date.toTimeString().substr(0, 8)
    )
  }
}
var getfromInfo = async function () {
  const columnList = {}
  const w = await this.http.get("index/workexperience") // 工作经验
  const s = await this.http.get("index/province") // 省份
  const g = await this.http.get("index/gangwei") // 岗位
  const z = await this.http.get("index/zhiwu") // 职务
  const e = await this.http.get("index/education") // 学历
  const x = await this.http.get("index/xinzirange") // 薪资范围
  const f = await this.http.get("index/fulilabel") // 福利待遇
  const c = await this.http.get("recruit/companys") // 招聘公司
  const p = await this.http.get("index/pintype") // 聘用方式
  
  columnList.workexperienceList = w.data
  columnList.provinceList = s.data
  columnList.gangweiList = g.data
  columnList.zhiwuList = z.data
  columnList.educationList = e.data
  columnList.xinzirangeList = x.data
  columnList.fulilabelList = f.data
  columnList.pinyongList = p.data
  
 let dataC = [];
  if(Array.isArray(c.data)){
	  c.data.forEach((ele)=>{
		  dataC.push({
			  id : ele.id ,
			  name : ele.name
		  })
	  });
	  
  };
  
  columnList.gongsilabelList = dataC;
    
  return columnList
}
export default {
  install: (Vue, options) => {
    Vue.prototype.toast = toast
    Vue.prototype.strToArray = strToArray
    Vue.prototype.getData = getData
    Vue.prototype.getfromInfo = getfromInfo
  }
}